﻿using System;
using System.Runtime.InteropServices;

namespace WebCamera.WebSocket
{
    public class fMP4
    {
        [UnmanagedFunctionPointer(CallingConvention.StdCall)]
        public delegate void fMP4Callback([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] byte[] data, int len, IntPtr userData);

        public const string DllName = "fMP4.dll";

        [DllImport(DllName, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern IntPtr fMP4_CreateH264();

        [DllImport(DllName, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern int fMP4_WriteH264(IntPtr handle, byte[] data, int len);

        [DllImport(DllName, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern void fMP4_SetCallback(IntPtr handle, fMP4Callback callback, IntPtr userData);

        [DllImport(DllName, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        public static extern void fMP4_Close(IntPtr handle);
    }
}
